<?php

class Access_Acl extends Zend_Acl{
	
	public function __construct(){
		
//		ACL ROLES

		$this->addRole(new Zend_Acl_Role(Access_Roles::GUEST));
		$this->addRole(new Zend_Acl_Role(Access_Roles::USER));
		$this->addRole(new Zend_Acl_Role(Access_Roles::EMP_CS),Access_Roles::USER);
		$this->addRole(new Zend_Acl_Role(Access_Roles::EMP_WH), Access_Roles::USER);
		$this->addRole(new Zend_Acl_Role(Access_Roles::EMP_FN), 
						array(
							Access_Roles::EMP_CS,
							Access_Roles::EMP_WH
						));
		$this->addRole(new Zend_Acl_Role(Access_Roles::ADMIN), Access_Roles::EMP_FN);
		$this->addRole(new Zend_Acl_Role(Access_Roles::SUADMIN), Access_Roles::ADMIN);
		
		
		
//		ACL RESOURCES

		$this->add(new Zend_Acl_Resource(Access_Resources::USER_CREATE));
		$this->add(new Zend_Acl_Resource(Access_Resources::USER_READ));
		$this->add(new Zend_Acl_Resource(Access_Resources::USER_UPDATE));
		$this->add(new Zend_Acl_Resource(Access_Resources::USER_ADD));
		$this->add(new Zend_Acl_Resource(Access_Resources::USER_DELETE));
		$this->add(new Zend_Acl_Resource(Access_Resources::USER_LOGIN));
		$this->add(new Zend_Acl_Resource(Access_Resources::USER_LOGOUT));
		$this->add(new Zend_Acl_Resource(Access_Resources::USER_SHIPLABEL));

		$this->add(new Zend_Acl_Resource(Access_Resources::USER_FEEDBACK));
		$this->add(new Zend_Acl_Resource(Access_Resources::USER_RPLYFEEDBACK));

		$this->add(new Zend_Acl_Resource(Access_Resources::OFFER));
		$this->add(new Zend_Acl_Resource(Access_Resources::CART));
		$this->add(new Zend_Acl_Resource(Access_Resources::INDEX));
		$this->add(new Zend_Acl_Resource(Access_Resources::SEARCH));
		$this->add(new Zend_Acl_Resource(Access_Resources::CHECKOUT));
		$this->add(new Zend_Acl_Resource(Access_Resources::CONFIRM));
		$this->add(new Zend_Acl_Resource(Access_Resources::ORDER_READ));
		$this->add(new Zend_Acl_Resource(Access_Resources::ORDER_UPDATE));
		$this->add(new Zend_Acl_Resource(Access_Resources::ORDER_DELETE));
		$this->add(new Zend_Acl_Resource(Access_Resources::ASSETS));
		$this->add(new Zend_Acl_Resource(Access_Resources::DOCTRINE));
		$this->add(new Zend_Acl_Resource(Access_Resources::ADMIN_USER));
		$this->add(new Zend_Acl_Resource(Access_Resources::ADMIN_ORDER));
		$this->add(new Zend_Acl_Resource(Access_Resources::ADMIN_SHIP));
		
//		ROLE RESOURCE NETWORK

		$this->deny();
		
//		Guest Access
		$this->allow(Access_Roles::GUEST, Access_Resources::INDEX);
		$this->allow(Access_Roles::GUEST, Access_Resources::SEARCH);
		$this->allow(Access_Roles::GUEST, Access_Resources::USER_CREATE);
		$this->allow(Access_Roles::GUEST, Access_Resources::USER_LOGIN);
		$this->allow(Access_Roles::GUEST, Access_Resources::OFFER);
		$this->allow(Access_Roles::GUEST, Access_Resources::CART);
		
//		User Access
		$this->allow(Access_Roles::USER, Access_Resources::INDEX);
		$this->allow(Access_Roles::USER, Access_Resources::SEARCH);
		$this->allow(Access_Roles::USER, Access_Resources::USER_READ);
		$this->allow(Access_Roles::USER, Access_Resources::USER_UPDATE);
		$this->allow(Access_Roles::USER, Access_Resources::USER_ADD);
		$this->allow(Access_Roles::USER, Access_Resources::USER_DELETE);
		$this->allow(Access_Roles::USER, Access_Resources::USER_LOGOUT);
		$this->allow(Access_Roles::USER, Access_Resources::USER_SHIPLABEL);
		$this->allow(Access_Roles::USER, Access_Resources::USER_FEEDBACK);
		$this->allow(Access_Roles::USER, Access_Resources::OFFER);
		$this->allow(Access_Roles::USER, Access_Resources::CART);
		$this->allow(Access_Roles::USER, Access_Resources::CHECKOUT);
		$this->allow(Access_Roles::USER, Access_Resources::CONFIRM);
		$this->allow(Access_Roles::USER, Access_Resources::ORDER_READ);	
		
//		EMP_CS
		$this->allow(Access_Roles::EMP_CS, Access_Resources::USER_RPLYFEEDBACK);

		
//		EMP_WH
		$this->allow(Access_Roles::EMP_WH, Access_Resources::ORDER_UPDATE);
		
//		EMP_FN
		$this->allow(Access_Roles::EMP_FN, Access_Resources::ORDER_DELETE);
	
//		ADMIN/SUADMIN
		$this->allow(Access_Roles::ADMIN, Access_Resources::USER_CREATE);
		$this->allow(Access_Roles::ADMIN, Access_Resources::DOCTRINE);
		$this->allow(Access_Roles::ADMIN, Access_Resources::ASSETS);
		$this->allow(Access_Roles::ADMIN, Access_Resources::ADMIN_USER);
		$this->allow(Access_Roles::ADMIN, Access_Resources::ADMIN_ORDER);
		$this->allow(Access_Roles::ADMIN, Access_Resources::ADMIN_SHIP);
		
	}	
}
